using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Linq;
using System.Threading.Tasks;
using Microsoft.AspNetCore.Mvc;
using Microsoft.Extensions.Logging;
using ShopForWeb.Services;
using ShopForWeb.UI.Utils.Filters;

namespace ShopForWeb.UI.Areas.Admin.Controllers
{
  [Area("admin")]
    [Route("[area]/[controller]")]
    [AdminAuthroize]
    public class OrderController : Controller
    {
        private readonly ILogger<OrderController> _logger;
        private  OrderService _orderService;
        public OrderController(ILogger<OrderController> logger,OrderService orderService)
        {
            _logger = logger;
            _orderService=orderService;
        }

        public IActionResult Index()
        {
            return View();
        }
        [HttpGet("report")]
     public async Task<IActionResult> GetMonthReportAsync([FromQuery]int year=2024)
     {
       var result=await _orderService.GetMonthReportAsync(year);
       return Json(result);
     }
     [HttpGet("{orderId}")]
          public async Task<IActionResult> GetByIdAsync([FromRoute]string orderId,[FromServices]OrderDetailService orderDetailService)
     {
       return Json(new
       {
        Order=await _orderService.GetByIdAsync(orderId),
        Details=await orderDetailService.GetByOrderIdAsync(orderId)
       });
     }
      
    }
}